package com.framework.controller.yhbcontroller;

import com.framework.exception.util.RespResult;
import com.framework.service.yhbservice.YhbRecommendMerchantService;
import com.framework.yhbEntity.view.CusTranView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 推荐商户接口
 */
@RequestMapping("recommend")
@Api(value = "推荐商户模块",tags = {"推荐商户模块"})
@RestController
public class YhbMerchantController {


    @Autowired
    private YhbRecommendMerchantService yhbRecommendMerchantService;


    @PostMapping("user/recommendMerchant")
    @ApiOperation("推荐商户")
    @ApiImplicitParams({
            @ApiImplicitParam(name="phone",value="手机号码",dataType="string", paramType = "query" ,required = true),
    })
    public RespResult recommendMerchant(String token,Long agentId,String name,String phone){
        Map<String, Object> map = yhbRecommendMerchantService.recommendMerchant(token, agentId, name, phone);
        return RespResult.ok(map);
    }

    /**
     * 根据token获取推荐商户列表
     * @param token
     * @return
     */
    @GetMapping("user/getMerchantList")
    @ApiOperation("获取商户列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="string", paramType = "query" ,required = true),
    })
    public RespResult getMerchantList(String token,Integer pageNo){
        List<CusTranView> list=yhbRecommendMerchantService.getMerchantList(token,pageNo);
        return RespResult.ok().put("list",list);
    }

    @GetMapping("user/getMerchantInfo")
    @ApiOperation("获取推荐商户页面信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="token",value="登录产生的token",dataType="string", paramType = "query" ,required = true),
    })
    public RespResult getMerchantInfo(String token){
        Map<String,Object> map=yhbRecommendMerchantService.getMerchantInfo(token);
        return RespResult.ok(map);
    }

}
